﻿/**
 * @file		ct_dd_pmc_temp_sensor_if.c
 * @brief		PMC Temperature Sensor IF driver Component Test
 * @note		None
 * @attention	None
 * 
 * <B><I>Copyright 2016 Socionext Inc.</I></B>
 */

#include <stdlib.h>
#include <string.h>
#include "driver_common.h"
#include "ct_dd_pmc_temp_sensor_if.h"
#include "dd_pmc_temp_sensor_if.h"
#include "pmc.h"

/*----------------------------------------------------------------------*/
/* Definition															*/
/*----------------------------------------------------------------------*/
// Nothing Special

/*----------------------------------------------------------------------*/
/* Enumeration															*/
/*----------------------------------------------------------------------*/
// Nothing Special

/*----------------------------------------------------------------------*/
/* Structure															*/
/*----------------------------------------------------------------------*/
// Nothing Special

/*----------------------------------------------------------------------*/
/* Global Data															*/
/*----------------------------------------------------------------------*/
// Nothing Special

/*----------------------------------------------------------------------*/
/* Local Method Definition												*/
/*----------------------------------------------------------------------*/
// Nothing Special

/*----------------------------------------------------------------------*/
/* Local Function														*/
/*----------------------------------------------------------------------*/
static VOID ct_dd_pmc_ts_if_callback(ULONG result);

/**
Temperature Sensor IF callback function.
*/
static VOID ct_dd_pmc_ts_if_callback(ULONG result)
{
	Ddim_Print(("Temperature Sensor IF Callback : 0x%08x\n", result));
}

/*----------------------------------------------------------------------*/
/* Global Function														*/
/*----------------------------------------------------------------------*/
/**
 * @brief  Command main function for Temperature Sensor IF test.
 * @param  int argc	:The number of parameters
 *		   char** argv	:The value of parameters
 * @return VOID
 *
 *		The meaning of parameters
 *		+--------+-------+-------+-------+-------------------------------------------------------+
 *		| P1     | P2    | P3    | P4    |  Meaning                                              |
 *		+--------+-------+-------+-------+-------------------------------------------------------+
 *		| info   | 0     |               | Get Macro Information                                 |
 *		|        +-------+---------------+-------------------------------------------------------+
 *		|        | 1     |               | Get Macro Information (Null parameter)                |
 *		+--------+-------+-------+-------+-------------------------------------------------------+
 *		| config | set   | 0/1   |       | Set Config Information (0:Each Sensor, 1:All Sensors) |
 *		|        +-------+-------+-------+-------------------------------------------------------+
 *		|        | get   | 0     |       | Get Config Information                                |
 *		|        |       +-------+-------+-------------------------------------------------------+
 *		|        |       | 1     |       | Get Config Information (Null parameter)               |
 *		+--------+-------+-------+-------+-------------------------------------------------------+
 *		| reset  | 0/1   | 0/1   |       | Set Reset   P2 - 0:All Sensors, 1:Sensor#0            |
 *		|        |       |       |       |             P3 - 0:reset enablement, 1:reset release  |
 *		+--------+-------+-------+-------+-------------------------------------------------------+
 *		| ctrl   | set   | 0     | 0     | Set Control of All Sensors (pattern 1)                |
 *		|        |       |       +-------+-------------------------------------------------------+
 *		|        |       |       | 1     | Set Control of All Sensors (pattern 2)                |
 *		|        |       |       +-------+-------------------------------------------------------+
 *		|        |       |       | 2     | Set Control of All Sensors (Null parameter)           |
 *		|        |       +-------+-------+-------------------------------------------------------+
 *		|        |       | 1     | 0     | Set Control of Each Sensor (pattern 1)                |
 *		|        |       |       +-------+-------------------------------------------------------+
 *		|        |       |       | 1     | Set Control of Each Sensor (pattern 2)                |
 *		|        |       |       +-------+-------------------------------------------------------+
 *		|        |       |       | 2     | Set Control of Each Sensor (Null parameter)           |
 *		|        +-------+-------+-------+-------------------------------------------------------+
 *		|        | get   | 0     | 0     | Get Control of All Sensors                            |
 *		|        |       |       +-------+-------------------------------------------------------+
 *		|        |       |       | 1     | Get Control of All Sensors (Null parameter)           |
 *		|        |       +-------+-------+-------------------------------------------------------+
 *		|        |       | 1     | 0     | Get Control of Each Sensor                            |
 *		|        |       |       +-------+-------------------------------------------------------+
 *		|        |       |       | 1     | Get Control of Each Sensor (Null parameter)           |
 *		+--------+-------+-------+-------+-------------------------------------------------------+
 *		| tsdata | 0     |               | Get Temperature Sensor IF Data                        |
 *		|        +-------+---------------+-------------------------------------------------------+
 *		|        | 1     |               | Get Temperature Sensor IF Data (Null parameter)       |
 *		+--------+-------+-------+-------+-------------------------------------------------------+
 *		| irq    | 0     | 0     |       | Get IRQ Status of All Sensors                         |
 *		|        |       +-------+-------+-------------------------------------------------------+
 *		|        |       | 1     |       | Get IRQ Status of All Sensors (Null parameter)        |
 *		|        +-------+-------+-------+-------------------------------------------------------+
 *		|        | 1     | 0     |       | Get IRQ Status of Each Sensor                         |
 *		|        |       +-------+-------+-------------------------------------------------------+
 *		|        |       | 1     |       | Get IRQ Status of Each Sensor (Null parameter)        |
 *		+--------+-------+-------+-------+-------------------------------------------------------+
 */                                      
VOID Ct_Dd_Pmc_TS_IF_Main(int argc, char** argv)
{
	INT32						ret;
	int							param2;
	int							param3;
	int							param4;
	T_DD_PMC_TS_IF_MACRO_INFO	info;
	E_DD_PMC_TS_IF_CONFIG		config;
	T_DD_PMC_TS_IF_ALL			ctrl_all;
	T_DD_PMC_TS_IF_EACH			ctrl;
	T_DD_PMC_TS_IF_TS_DATA		ts_data;
	U_DD_PMC_TS_IF_IRQ_ALL		irq_all;
	U_DD_PMC_TS_IF_IRQ_SENSOR	irq_sensor;
	
	if(strcmp(argv[1], "info") == 0){
		// get 2nd paramter.
		param2 = atoi(argv[2]);
		if (param2 == 0) {
			// data clear.
			memset(&info, 0, sizeof(T_DD_PMC_TS_IF_MACRO_INFO));
			// get macro info.
			ret = Dd_PMC_TS_IF_Get_Macro_Info(&info);
			if (ret == D_DDIM_OK) {
				Ddim_Print(("Dd_PMC_TS_IF_Get_Macro_Info : OK\n"));
				// register data output.
				Ddim_Print(("--- Temp Sensor IF Register ---\n"));
				Ddim_Print(("MACROINFO : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.MACROINFO.word));
				// get data output.
				Ddim_Print(("--- Get Data ------------------\n"));
				Ddim_Print(("ts_num    : %d\n", info.ts_num));
				Ddim_Print(("macro_rev : %d\n", info.macro_rev));
				Ddim_Print(("macro_id  : %d\n", info.macro_id));
				Ddim_Print(("-------------------------------\n"));
			}
			else {
				Ddim_Print(("Dd_PMC_TS_IF_Get_Macro_Info : NG  ret=0x%08x\n", ret));
			}
		}
		else if (param2 == 1) {
			// input paramter error.
			ret = Dd_PMC_TS_IF_Get_Macro_Info(NULL);
			Ddim_Print(("Dd_PMC_TS_IF_Get_Macro_Info : NG  ret=0x%08x\n", ret));
		}
		else {
			Ddim_Print(("please check 2nd parameter!!\n"));
		}
	}
	else if(strcmp(argv[1], "config") == 0){
		if(strcmp(argv[2], "set") == 0){
			// get 3rd paramter.
			param3 = atoi(argv[3]);
			if ((param3 == 0) || (param3 == 1)) {
				// Set All Config.
				Dd_PMC_TS_IF_Set_All_Config((E_DD_PMC_TS_IF_CONFIG)param3);
				Ddim_Print(("Dd_PMC_TS_IF_Set_All_Config : execute.\n"));
				// register data output.
				Ddim_Print(("--- Temp Sensor IF Register ---\n"));
				Ddim_Print(("ALLCONFIG : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
				Ddim_Print(("-------------------------------\n"));
			}
			else {
				Ddim_Print(("please check 3rd parameter!!\n"));
			}
		}
		else if(strcmp(argv[2], "get") == 0){
			// get 3rd paramter.
			param3 = atoi(argv[3]);
			if (param3 == 0) {
				// data clear.
				config = E_DD_PMC_TS_IF_CONFIG_EACH_SETTING;
				// Get All Config.
				ret = Dd_PMC_TS_IF_Get_Config_Mode(&config);
				if (ret == D_DDIM_OK) {
					Ddim_Print(("Dd_PMC_TS_IF_Get_Config_Mode : OK\n"));
					// register data output.
					Ddim_Print(("--- Temp Sensor IF Register ---\n"));
					Ddim_Print(("ALLCONFIG : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
					// get data output.
					Ddim_Print(("--- Get Data ------------------\n"));
					Ddim_Print(("config    : %d\n", config));
					Ddim_Print(("-------------------------------\n"));
				}
				else {
					Ddim_Print(("Dd_PMC_TS_IF_Get_Config_Mode : NG  ret=0x%08x\n", ret));
				}
			}
			else if (param3 == 1) {
				// input paramter error.
				ret = Dd_PMC_TS_IF_Get_Config_Mode(NULL);
				Ddim_Print(("Dd_PMC_TS_IF_Get_Config_Mode : NG  ret=0x%08x\n", ret));
			}
			else {
				Ddim_Print(("please check 3rd parameter!!\n"));
			}
		}
		else {
			Ddim_Print(("please check 2nd parameter!!\n"));
		}
	}
	else if(strcmp(argv[1], "reset") == 0){
		// get 2nd paramter.
		param2 = atoi(argv[2]);
		// get 3rd paramter.
		param3 = atoi(argv[3]);
		
		if ((param2 == 0) || (param2 == 1)) {
			// Reset.
			ret = Dd_PMC_TS_IF_Reset((E_DD_PMC_TS_IF_TYPE)param2, param3);
			if (ret == D_DDIM_OK) {
				Ddim_Print(("Dd_PMC_TS_IF_Reset : OK\n"));
				// register data output.
				Ddim_Print(("--- Temp Sensor IF Register ---\n"));
				Ddim_Print(("ALLCONFIG       : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
				Ddim_Print(("TS_RESET        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.TS_RESET.word));
				Ddim_Print(("SENSOR.TS_RESET : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_RESET.word));
				Ddim_Print(("-------------------------------\n"));
			}
			else {
				Ddim_Print(("Dd_PMC_TS_IF_Reset : NG  ret=0x%08x\n", ret));
			}
		}
		else {
			Ddim_Print(("please check 2nd parameter!!\n"));
		}
	}
	else if(strcmp(argv[1], "ctrl") == 0){
		if(strcmp(argv[2], "set") == 0){
			// get 3rd paramter.
			param3 = atoi(argv[3]);
			// get 4th paramter.
			param4 = atoi(argv[4]);
			
			if (param3 == 0) {
				// All Sensors.
				if (param4 == 0) {
					// Set control data.
					ctrl_all.ts_reset					= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.ts_en						= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.hys_temp					= 0x00;
					ctrl_all.ts_ct						= E_DD_PMC_TS_IF_CT_0;
					ctrl_all.irq_mask.bit.ts_irq_0		= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.irq_mask.bit.all_lf_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.irq_mask.bit.all_ln_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.irq_mask.bit.all_hn_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.irq_mask.bit.all_hf_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.irq_mask.bit.any_lf_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.irq_mask.bit.any_ln_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.irq_mask.bit.any_hn_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.irq_mask.bit.any_hf_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.hi_full_temp				= 0x00000280;
					ctrl_all.hi_near_temp				= 0x00000230;
					ctrl_all.lo_full_temp				= 0xFFFFFF60;
					ctrl_all.lo_near_temp				= 0xFFFFFF10;
					ctrl_all.callback					= (VP_CALLBACK)ct_dd_pmc_ts_if_callback;
					// set Control All Sensors.
					ret = Dd_PMC_TS_IF_Set_Control_All_Sensors(&ctrl_all);
					if (ret == D_DDIM_OK) {
						Ddim_Print(("Dd_PMC_TS_IF_Set_Control_All_Sensors : OK\n"));
						// register data output.
						Ddim_Print(("--- Temp Sensor IF Register ---\n"));
						Ddim_Print(("ALLCONFIG    : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
						Ddim_Print(("IRQMASK      : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.IRQMASK.word));
						Ddim_Print(("HI_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HI_FULL_TEMP));
						Ddim_Print(("HI_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HI_NEAR_TEMP));
						Ddim_Print(("LO_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.LO_NEAR_TEMP));
						Ddim_Print(("LO_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.LO_FULL_TEMP));
						Ddim_Print(("HYS_TEMP     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HYS_TEMP.word));
						Ddim_Print(("TS_CT        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.TS_CT.word));
						Ddim_Print(("TS_EN        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.TS_EN.word));
						Ddim_Print(("-------------------------------\n"));
					}
					else {
						Ddim_Print(("Dd_PMC_TS_IF_Set_Control_All_Sensors : NG  ret=0x%08x\n", ret));
					}
				}
				else if (param4 == 1) {
					// Set control data.
					ctrl_all.ts_reset					= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.ts_en						= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl_all.hys_temp					= 0xFF;
					ctrl_all.ts_ct						= E_DD_PMC_TS_IF_CT_0;
					ctrl_all.irq_mask.bit.ts_irq_0		= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.irq_mask.bit.all_lf_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.irq_mask.bit.all_ln_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.irq_mask.bit.all_hn_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.irq_mask.bit.all_hf_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.irq_mask.bit.any_lf_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.irq_mask.bit.any_ln_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.irq_mask.bit.any_hn_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.irq_mask.bit.any_hf_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl_all.hi_full_temp				= 0x00000120;
					ctrl_all.hi_near_temp				= 0x00000110;
					ctrl_all.lo_full_temp				= 0xFFFFFF30;
					ctrl_all.lo_near_temp				= 0xFFFFFEF0;
					ctrl_all.callback					= (VP_CALLBACK)ct_dd_pmc_ts_if_callback;
					// set Control All Sensors.
					ret = Dd_PMC_TS_IF_Set_Control_All_Sensors(&ctrl_all);
					if (ret == D_DDIM_OK) {
						Ddim_Print(("Dd_PMC_TS_IF_Set_Control_All_Sensors : OK\n"));
						// register data output.
						Ddim_Print(("--- Temp Sensor IF Register ---\n"));
						Ddim_Print(("ALLCONFIG    : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
						Ddim_Print(("IRQMASK      : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.IRQMASK.word));
						Ddim_Print(("HI_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HI_FULL_TEMP));
						Ddim_Print(("HI_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HI_NEAR_TEMP));
						Ddim_Print(("LO_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.LO_NEAR_TEMP));
						Ddim_Print(("LO_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.LO_FULL_TEMP));
						Ddim_Print(("HYS_TEMP     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HYS_TEMP.word));
						Ddim_Print(("TS_CT        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.TS_CT.word));
						Ddim_Print(("TS_EN        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.TS_EN.word));
						Ddim_Print(("-------------------------------\n"));
					}
					else {
						Ddim_Print(("Dd_PMC_TS_IF_Set_Control_All_Sensors : NG  ret=0x%08x\n", ret));
					}
				}
				else if (param4 == 2) {
					// Input parameter error.
					ret = Dd_PMC_TS_IF_Set_Control_All_Sensors(NULL);
					Ddim_Print(("Dd_PMC_TS_IF_Set_Control_All_Sensors : NG  ret=0x%08x\n", ret));
				}
				else {
					Ddim_Print(("please check 4th parameter!!\n"));
				}
			}
			else if (param3 == 1) {
				// Sensor#0.
				if (param4 == 0) {
					// Set control data.
					ctrl.ts_reset				= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl.ts_en					= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl.hys_temp				= 0x00;
					ctrl.ts_ct					= E_DD_PMC_TS_IF_CT_0;
					ctrl.irq_mask.bit.lf_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl.irq_mask.bit.ln_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl.irq_mask.bit.hn_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl.irq_mask.bit.hf_irq	= D_DD_PMC_TS_IF_ENABLE_ON;
					ctrl.hi_full_temp			= 0x00000280;
					ctrl.hi_near_temp			= 0x00000230;
					ctrl.lo_full_temp			= 0xFFFFFF60;
					ctrl.lo_near_temp			= 0xFFFFFF10;
					ctrl.callback				= (VP_CALLBACK)ct_dd_pmc_ts_if_callback;
					// set Control each Sensor.
					ret = Dd_PMC_TS_IF_Set_Control_Each_Sensor(&ctrl);
					if (ret == D_DDIM_OK) {
						Ddim_Print(("Dd_PMC_TS_IF_Set_Control_Each_Sensor : OK\n"));
						// register data output.
						Ddim_Print(("--- Temp Sensor IF Register ---\n"));
						Ddim_Print(("ALLCONFIG             : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
						Ddim_Print(("SENSOR - HI_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HI_FULL_TEMP));
						Ddim_Print(("SENSOR - HI_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HI_NEAR_TEMP));
						Ddim_Print(("SENSOR - LO_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.LO_NEAR_TEMP));
						Ddim_Print(("SENSOR - LO_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.LO_FULL_TEMP));
						Ddim_Print(("SENSOR - HYS_TEMP     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HYS_TEMP.word));
						Ddim_Print(("SENSOR - IRQMASK      : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.IRQMASK.word));
						Ddim_Print(("SENSOR - TS_CT        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_CT.word));
						Ddim_Print(("SENSOR - TS_EN        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_EN.word));
						Ddim_Print(("SENSOR - TS_RESET     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_RESET.word));
						Ddim_Print(("-------------------------------\n"));
					}
					else {
						Ddim_Print(("Dd_PMC_TS_IF_Set_Control_Each_Sensor : NG  ret=0x%08x\n", ret));
					}
				}
				else if (param4 == 1) {
					// Set control data.
					ctrl.ts_reset				= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl.ts_en					= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl.hys_temp				= 0xFF;
					ctrl.ts_ct					= E_DD_PMC_TS_IF_CT_3;
					ctrl.irq_mask.bit.lf_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl.irq_mask.bit.ln_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl.irq_mask.bit.hn_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl.irq_mask.bit.hf_irq	= D_DD_PMC_TS_IF_ENABLE_OFF;
					ctrl.hi_full_temp			= 0x00000100;
					ctrl.hi_near_temp			= 0x00000050;
					ctrl.lo_full_temp			= 0xFFFFFFF0;
					ctrl.lo_near_temp			= 0xFFFFFF40;
					ctrl.callback				= (VP_CALLBACK)ct_dd_pmc_ts_if_callback;
					// set Control each Sensor.
					ret = Dd_PMC_TS_IF_Set_Control_Each_Sensor(&ctrl);
					if (ret == D_DDIM_OK) {
						Ddim_Print(("Dd_PMC_TS_IF_Set_Control_Each_Sensor : OK\n"));
						// register data output.
						Ddim_Print(("--- Temp Sensor IF Register ---\n"));
						Ddim_Print(("ALLCONFIG             : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
						Ddim_Print(("SENSOR - HI_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HI_FULL_TEMP));
						Ddim_Print(("SENSOR - HI_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HI_NEAR_TEMP));
						Ddim_Print(("SENSOR - LO_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.LO_NEAR_TEMP));
						Ddim_Print(("SENSOR - LO_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.LO_FULL_TEMP));
						Ddim_Print(("SENSOR - HYS_TEMP     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HYS_TEMP.word));
						Ddim_Print(("SENSOR - IRQMASK      : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.IRQMASK.word));
						Ddim_Print(("SENSOR - TS_CT        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_CT.word));
						Ddim_Print(("SENSOR - TS_EN        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_EN.word));
						Ddim_Print(("SENSOR - TS_RESET     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_RESET.word));
						Ddim_Print(("-------------------------------\n"));
					}
					else {
						Ddim_Print(("Dd_PMC_TS_IF_Set_Control_Each_Sensor : NG  ret=0x%08x\n", ret));
					}
				}
				else if (param4 == 2) {
					// Input parameter error.
					ret = Dd_PMC_TS_IF_Set_Control_Each_Sensor(NULL);
					Ddim_Print(("Dd_PMC_TS_IF_Set_Control_Each_Sensor : NG  ret=0x%08x\n", ret));
				}
				else {
					Ddim_Print(("please check 4th parameter!!\n"));
				}
			}
			else {
				Ddim_Print(("please check 3rd parameter!!\n"));
			}
		}
		else if(strcmp(argv[2], "get") == 0){
			// get 3rd paramter.
			param3 = atoi(argv[3]);
			// get 4th paramter.
			param4 = atoi(argv[4]);
			
			if (param3 == 0) {
				// All Sensors.
				if (param4 == 0) {
					// clear control data.
					memset(&ctrl_all, 0, sizeof(T_DD_PMC_TS_IF_ALL));
					// get Control All Sensors.
					ret = Dd_PMC_TS_IF_Get_Control_All_Sensors(&ctrl_all);
					if (ret == D_DDIM_OK) {
						Ddim_Print(("Dd_PMC_TS_IF_Get_Control_All_Sensors : OK\n"));
						// register data output.
						Ddim_Print(("--- Temp Sensor IF Register ---\n"));
						Ddim_Print(("ALLCONFIG    : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
						Ddim_Print(("IRQMASK      : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.IRQMASK.word));
						Ddim_Print(("HI_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HI_FULL_TEMP));
						Ddim_Print(("HI_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HI_NEAR_TEMP));
						Ddim_Print(("LO_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.LO_NEAR_TEMP));
						Ddim_Print(("LO_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.LO_FULL_TEMP));
						Ddim_Print(("HYS_TEMP     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HYS_TEMP.word));
						Ddim_Print(("HYS_TEMP     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.HYS_TEMP.word));
						Ddim_Print(("TS_CT        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.TS_CT.word));
						Ddim_Print(("TS_EN        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.TS_EN.word));
						// get data output.
						Ddim_Print(("--- Get Data ------------------\n"));
						Ddim_Print(("irq_mask     : 0x%08x\n", ctrl_all.irq_mask.word));
						Ddim_Print(("hi_full_temp : 0x%08x\n", ctrl_all.hi_full_temp));
						Ddim_Print(("hi_near_temp : 0x%08x\n", ctrl_all.hi_near_temp));
						Ddim_Print(("lo_full_temp : 0x%08x\n", ctrl_all.lo_full_temp));
						Ddim_Print(("lo_near_temp : 0x%08x\n", ctrl_all.lo_near_temp));
						Ddim_Print(("hys_temp     : 0x%08x\n", ctrl_all.hys_temp));
						Ddim_Print(("ts_ct        : 0x%08x\n", ctrl_all.ts_ct));
						Ddim_Print(("ts_en        : 0x%08x\n", ctrl_all.ts_en));
						Ddim_Print(("callback     : 0x%08x\n", ctrl_all.callback));
						Ddim_Print(("-------------------------------\n"));
					}
					else {
						Ddim_Print(("Dd_PMC_TS_IF_Get_Control_All_Sensors : NG  ret=0x%08x\n", ret));
					}
				}
				else if (param4 == 1) {
					// Input parameter error.
					ret = Dd_PMC_TS_IF_Get_Control_All_Sensors(NULL);
					Ddim_Print(("Dd_PMC_TS_IF_Get_Control_All_Sensors : NG  ret=0x%08x\n", ret));
				}
				else {
					Ddim_Print(("please check 4th parameter!!\n"));
				}
			}
			else if (param3 == 1) {
				// Sensor#0.
				if (param4 == 0) {
					// Clear control data.
					memset(&ctrl, 0, sizeof(T_DD_PMC_TS_IF_EACH));
					// get Control each Sensor.
					ret = Dd_PMC_TS_IF_Get_Control_Each_Sensor(&ctrl);
					if (ret == D_DDIM_OK) {
						Ddim_Print(("Dd_PMC_TS_IF_Get_Control_Each_Sensor : OK\n"));
						// register data output.
						Ddim_Print(("--- Temp Sensor IF Register ---\n"));
						Ddim_Print(("ALLCONFIG             : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.ALLCONFIG.word));
						Ddim_Print(("SENSOR - HI_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HI_FULL_TEMP));
						Ddim_Print(("SENSOR - HI_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HI_NEAR_TEMP));
						Ddim_Print(("SENSOR - LO_NEAR_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.LO_NEAR_TEMP));
						Ddim_Print(("SENSOR - LO_FULL_TEMP : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.LO_FULL_TEMP));
						Ddim_Print(("SENSOR - HYS_TEMP     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.HYS_TEMP.word));
						Ddim_Print(("SENSOR - IRQMASK      : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.IRQMASK.word));
						Ddim_Print(("SENSOR - TS_CT        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_CT.word));
						Ddim_Print(("SENSOR - TS_EN        : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_EN.word));
						Ddim_Print(("SENSOR - TS_RESET     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TS_RESET.word));
						// get data output.
						Ddim_Print(("--- Get Data ------------------\n"));
						Ddim_Print(("ts_reset              : 0x%08x\n", ctrl.ts_reset));
						Ddim_Print(("ts_en                 : 0x%08x\n", ctrl.ts_en));
						Ddim_Print(("hys_temp              : 0x%08x\n", ctrl.hys_temp));
						Ddim_Print(("ts_ct                 : 0x%08x\n", ctrl.ts_ct));
						Ddim_Print(("irq_mask              : 0x%08x\n", ctrl.irq_mask.word));
						Ddim_Print(("hi_full_temp          : 0x%08x\n", ctrl.hi_full_temp));
						Ddim_Print(("hi_near_temp          : 0x%08x\n", ctrl.hi_near_temp));
						Ddim_Print(("lo_full_temp          : 0x%08x\n", ctrl.lo_full_temp));
						Ddim_Print(("lo_near_temp          : 0x%08x\n", ctrl.lo_near_temp));
						Ddim_Print(("callback              : 0x%08x\n", ctrl.callback));
						Ddim_Print(("-------------------------------\n"));
					}
					else {
						Ddim_Print(("Dd_PMC_TS_IF_Get_Control_Each_Sensor : NG  ret=0x%08x\n", ret));
					}
				}
				else if (param4 == 1) {
					// Input parameter error.
					ret = Dd_PMC_TS_IF_Get_Control_Each_Sensor(NULL);
					Ddim_Print(("Dd_PMC_TS_IF_Get_Control_Each_Sensor : NG  ret=0x%08x\n", ret));
				}
				else {
					Ddim_Print(("please check 4th parameter!!\n"));
				}
			}
			else {
				Ddim_Print(("please check 3rd parameter!!\n"));
			}
		}
		else {
			Ddim_Print(("please check 2nd parameter!!\n"));
		}
	}
	else if(strcmp(argv[1], "tsdata") == 0){
		// get 2nd paramter.
		param2 = atoi(argv[2]);
		if (param2 == 0) {
			// Clear control data.
			memset(&ts_data, 0, sizeof(T_DD_PMC_TS_IF_TS_DATA));
			// Get TS Data.
			ret = Dd_PMC_TS_IF_Get_TS_Data(&ts_data);
			if (ret == D_DDIM_OK) {
				Ddim_Print(("Dd_PMC_TS_IF_Get_TS_Data : OK\n"));
				// register data output.
				Ddim_Print(("--- Temp Sensor IF Register ---\n"));
				Ddim_Print(("SENSOR - TSDATA_VALID : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TSDATA_VALID.word));
				Ddim_Print(("SENSOR - TSDATA       : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.TSDATA));
				// get data output.
				Ddim_Print(("--- Get Data ------------------\n"));
				Ddim_Print(("ts_data_valid         : %d\n", ts_data.ts_data_valid));
				Ddim_Print(("ts_data               : 0x%08x\n", ts_data.ts_data));
				Ddim_Print(("-------------------------------\n"));
			}
			else {
				Ddim_Print(("Dd_PMC_TS_IF_Get_TS_Data : NG  ret=0x%08x\n", ret));
			}
		}
		else if (param2 == 1) {
			// Input parameter error.
			ret = Dd_PMC_TS_IF_Get_TS_Data(NULL);
			Ddim_Print(("Dd_PMC_TS_IF_Get_TS_Data : NG  ret=0x%08x\n", ret));
		}
		else {
			Ddim_Print(("please check 2nd parameter!!\n"));
		}
	}
	else if(strcmp(argv[1], "irq") == 0){
		// get 2nd paramter.
		param2 = atoi(argv[2]);
		// get 3rd paramter.
		param3 = atoi(argv[3]);
		
		if (param2 == 0) {
			// All Sensors.
			if (param3 == 0) {
				// Clear irq status.
				irq_all.word = 0;
				// Get IRQ Status of All Sensors.
				ret = Dd_PMC_TS_IF_Get_IRQ_Out_Status_All_Sensors(&irq_all);
				if (ret == D_DDIM_OK) {
					Ddim_Print(("Dd_PMC_TS_IF_Get_IRQ_Out_Status_All_Sensors : OK\n"));
					// register data output.
					Ddim_Print(("--- Temp Sensor IF Register ---\n"));
					Ddim_Print(("IRQOUT     : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.IRQOUT.word));
					// get data output.
					Ddim_Print(("--- Get Data ------------------\n"));
					Ddim_Print(("ts_irq_0   : %d\n", irq_all.bit.ts_irq_0));
					Ddim_Print(("all_lf_irq : %d\n", irq_all.bit.all_lf_irq));
					Ddim_Print(("all_ln_irq : %d\n", irq_all.bit.all_ln_irq));
					Ddim_Print(("all_hn_irq : %d\n", irq_all.bit.all_hn_irq));
					Ddim_Print(("all_hf_irq : %d\n", irq_all.bit.all_hf_irq));
					Ddim_Print(("any_lf_irq : %d\n", irq_all.bit.any_lf_irq));
					Ddim_Print(("any_ln_irq : %d\n", irq_all.bit.any_ln_irq));
					Ddim_Print(("any_hn_irq : %d\n", irq_all.bit.any_hn_irq));
					Ddim_Print(("any_hf_irq : %d\n", irq_all.bit.any_hf_irq));
					Ddim_Print(("-------------------------------\n"));
				}
				else {
					Ddim_Print(("Dd_PMC_TS_IF_Get_IRQ_Out_Status_All_Sensors : NG  ret=0x%08x\n", ret));
				}
			}
			else if (param3 == 1) {
				// Input parameter error.
				ret = Dd_PMC_TS_IF_Get_IRQ_Out_Status_All_Sensors(NULL);
				Ddim_Print(("Dd_PMC_TS_IF_Get_IRQ_Out_Status_All_Sensors : NG  ret=0x%08x\n", ret));
			}
			else {
				Ddim_Print(("please check 3rd parameter!!\n"));
			}
		}
		else if (param2 == 1) {
			// Sensor#0.
			if (param3 == 0) {
				// Clear irq status.
				irq_sensor.word = 0;
				// Get IRQ Status of Each Sensor.
				ret = Dd_PMC_TS_IF_Get_IRQ_Out_Status_Each_Sensor(&irq_sensor);
				if (ret == D_DDIM_OK) {
					Ddim_Print(("Dd_PMC_TS_IF_Get_IRQ_Out_Status_Each_Sensor : OK\n"));
					// register data output.
					Ddim_Print(("--- Temp Sensor IF Register ---\n"));
					Ddim_Print(("SENSOR - IRQOUT : 0x%08x\n", IO_PMC.TEMP_SENSOR_IF.SENSOR.IRQOUT.word));
					// get data output.
					Ddim_Print(("--- Get Data ------------------\n"));
					Ddim_Print(("lf_irq          : %d\n", irq_sensor.bit.lf_irq));
					Ddim_Print(("ln_irq          : %d\n", irq_sensor.bit.ln_irq));
					Ddim_Print(("hn_irq          : %d\n", irq_sensor.bit.hn_irq));
					Ddim_Print(("hf_irq          : %d\n", irq_sensor.bit.hf_irq));
					Ddim_Print(("-------------------------------\n"));
				}
				else {
					Ddim_Print(("Dd_PMC_TS_IF_Get_IRQ_Out_Status_Each_Sensor : NG  ret=0x%08x\n", ret));
				}
			}
			else if (param3 == 1) {
				// Input parameter error.
				ret = Dd_PMC_TS_IF_Get_IRQ_Out_Status_Each_Sensor(NULL);
				Ddim_Print(("Dd_PMC_TS_IF_Get_IRQ_Out_Status_Each_Sensor : NG  ret=0x%08x\n", ret));
			}
			else {
				Ddim_Print(("please check 3rd parameter!!\n"));
			}
		}
		else {
			Ddim_Print(("please check 2nd parameter!!\n"));
		}
	}
	else{
		Ddim_Print(("please check 1st parameter!!\n"));
	}
}
